package ore.example.pokemoninfo.GUI;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.impl.SimpleItem;
import xyz.xenondevs.invui.item.Item;
import xyz.xenondevs.invui.window.Window;
import ore.example.pokemoninfo.utils.ConvertPokemon;

public class PhotoConfirmGUI {

    public static void open(Player player, int partyIndex) {
        Item yes = new SimpleItem(new ItemBuilder(Material.LIME_CONCRETE)
                .setDisplayName("§a确认转换"), click -> {
            player.closeInventory();
            ConvertPokemon.convertPokemonToItem(player, partyIndex);
        });

        Item no = new SimpleItem(new ItemBuilder(Material.RED_CONCRETE)
                .setDisplayName("§c取消"), click -> player.closeInventory());

        Gui gui = Gui.normal()
                .setStructure(
                        "#########",
                        "###y#n###",
                        "#########"
                )
                .addIngredient('#', new SimpleItem(new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE).setDisplayName(" ")))
                .addIngredient('y', yes)
                .addIngredient('n', no)
                .build();

        Window window = Window.single()
                .setViewer(player)
                .setTitle("§e是否为此宝可梦转换？")
                .setGui(gui)
                .build();

        window.open();
    }
}
